
set(Clang_DIR ${MLIR_DIR}/../clang)
find_package(Clang REQUIRED CONFIG)
include_directories(${CLANG_INCLUDE_DIRS})
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})

list(APPEND CMAKE_MODULE_PATH "${CLANG_CMAKE_DIR}")
include(AddClang)
include(AddLLVM)

set(PROTO_FILE "./graph_node.proto")
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILE})

get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
get_property(translation_libs GLOBAL PROPERTY MLIR_TRANSLATION_LIBS)

add_clang_executable(wafer-frontend
                     waferfrontend.cpp
                     ${PROTO_SRCS}
                    #  ${PROTO_HDRS}
                     pragmaHandler.cpp
                     )

target_link_libraries(wafer-frontend
                      PRIVATE
                      MLIROptLib
                      MLIRExecutionEngine
                      clangTooling
                      ${dialect_libs}
                      ${conversion_libs}
                      ${translation_libs}
                      ${PROTOBUF_LIBRARY}

                      MLIRSSTDialect
                      MLIRHyperDialect
                      MLIRCryptoDialect
                      
                      SchedulingOnDevices
                      LowerHyperToDevice
                      LowerCryptoToGpu
                      LowerPadMessage
                      LowerCryptoToX86WithOutSHA1ISA
                      LowerCryptoToHyper
                      LowerSSTToLLVM

                     )